import {api} from './libs/api.js';
let _self;
export const index =  {
	data() {
		return {
			optLock:false,
			tabItem:0,
			tabSubItem:0,
			icons:[
				{type:"search",size:uni.upx2px(30)},
				{type:"scan",size:uni.upx2px(30)},
				{type:"search",size:uni.upx2px(40)},
			],
			dataList:[]
		}
	},
	onReachBottom:function(e){
		this.params.page+=1;
		this.initData();
	},
	
	mounted() {
		_self = this;
	},
	
	methods: {
		
		async selectTab(event){
			//console.log(event);
			let level=event.currentTarget.dataset.level;
			if(level=="1"){
				this.tabItem=event.currentTarget.dataset.id;	
				this.tabSubItem=0;
				
			}else if(level=="2"){
				this.tabSubItem=event.currentTarget.dataset.id;
			}
			
			this.initData();
		},
		async initData(){
			uni.showLoading({title: '加载中'});

			let dataInfo=await api.dataList(this.params);
			if(this.params.page==1){
				this.dataList=dataInfo["dataList"];
			}else{
				if(dataInfo["dataList"].length==0) this.params.page-=1;
				this.dataList.push.apply(this.dataList,dataInfo["dataList"]);
			}
			uni.hideLoading();
		},
		
		searchCancel(){
			this.params.name="";
			this.initData();
		},
		
		seachData(){this.initData();}
				
	},
}